package com.jzx.provider.cv.repository;

import com.jzx.provider.cv.model.ProjectInfo;
import com.jzx.provider.cv.model.WorkInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author daihuihui
 * @date 2019/2/5
 */
public interface ProjectInfoRepository extends JpaRepository<ProjectInfo, Integer> {
    /**
     * 根据简历id查找项目经历
     *
     * @param cvId 简历id
     * @return 工作经历列表
     */
    List<ProjectInfo> findByCvId(Long cvId);

    @Modifying
    @Query(nativeQuery = true, value = "update t_project_info set " +
            "start_date=:#{#projectInfo.startDate},end_date=:#{#projectInfo.endDate}," +
            "name=:#{#projectInfo.name},title=:#{#projectInfo.title},result=:#{#projectInfo.result}," +
            "company=:#{#projectInfo.company},des=:#{#projectInfo.des}," +
            "duties=:#{#projectInfo.duties},update_time=:#{#projectInfo.updateTime} where id=:#{#projectInfo.id}")
    void updateCvProjectInfo(ProjectInfo projectInfo);
}
